<!DOCTYPE html>
<html>
<style>
    .back{
        /*background: url("/imgs/春节.png") no-repeat 20px 5px;*/
        width: 100%;
        height: 100%;
        display: block;
        position: relative;
    }
    .back::after{
        content: "";
        background: url("/imgs/春节.png") repeat 0px 0px;
        /*background-size: cover;*/
        opacity: 0.5;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        position: absolute;
        z-index: -1;
    }
</style>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title> Pear Admin Layui </title>
    <!-- 依 赖 样 式 -->
    <link rel="stylesheet" href="../Pear-Admin-Layui/component/pear/css/pear.css"/>
    <!-- 加 载 样 式-->
    <link rel="stylesheet" href="../Pear-Admin-Layui/admin/css/load.css"/>
    <!-- 布 局 样 式 -->
    <link rel="stylesheet" href="../Pear-Admin-Layui/admin/css/admin.css"/>
    <!-- 主 题 更 换 -->
    <style id="pearadmin-bg-color"></style>
    <!-- 头 部 结 束 -->
    <link rel="shortcut icon" href="../ff.ico" type="image/x-icon">
</head>
<!-- 结 构 代 码 -->
<body class="layui-layout-body pear-admin">
<!-- 布 局 框 架 -->
<div class="layui-layout layui-layout-admin">
    <div class="layui-header back">
        <!-- 顶 部 左 侧 功 能 -->
        <ul class="layui-nav layui-layout-left">
            <li class="collaspe layui-nav-item"><a href="#" class="layui-icon layui-icon-shrink-right"></a></li>
            <li class="refresh layui-nav-item"><a href="#" class="layui-icon layui-icon-refresh-1" loading=600></a></li>
        </ul>
        <!-- 顶 部 右 侧 菜 单 -->
        <div id="control" class="layui-layout-control"></div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide-xs"><a href="#"
                                                        class="fullScreen layui-icon layui-icon-screen-full"></a></li>
            <li class="layui-nav-item">
                <!-- 头 像 -->
                <a href="javascript:;">
                    <img src="" class="layui-nav-img">
                    <span id="username">mwj</span>
                </a>
                <!-- 功 能 菜 单 -->
                <dl class="layui-nav-child">
                    <dd><a user-menu-url="../Pear-Admin-Layui/view/system/person.html" user-menu-id="5555"
                           user-menu-title="基本资料">基本资料</a></dd>
                    <dd><a href="#" id="logout">注销登录</a></dd>
                </dl>
            </li>
            <!-- 主 题 配 置 -->
            <li class="layui-nav-item setting"><a href="#" class="layui-icon layui-icon-more-vertical"></a></li>
        </ul>
    </div>
    <!-- 侧 边 区 域 -->
    <div class="layui-side layui-bg-black">
        <!-- 顶 部 图 标 -->
        <div class="layui-logo">
            <!-- 图 表 -->
            <img class="logo"></img>
            <!-- 标 题 -->
            <span class="title"></span>
        </div>
        <!-- 侧 边 菜 单 -->
        <div class="layui-side-scroll">
            <div id="sideMenu"></div>
        </div>
    </div>
    <!-- 视 图 页 面 -->
    <div class="layui-body">
        <!-- 内 容 页 面 -->
        <div id="content"></div>
    </div>
</div>
<!-- 遮 盖 层 -->
<div class="pear-cover"></div>
<!-- 移 动 端 便 捷 操 作 -->
<div class="pear-collasped-pe collaspe"><a href="#" class="layui-icon layui-icon-shrink-right"></a></div>
<!-- 加 载 动 画-->
<!--		<div class="loader-main">-->
<!--			<div class="loader"></div>-->
<!--		</div>-->
<!-- 依 赖 脚 本 -->
<script src='https://api.vvhan.com/api/snow'></script>
<script src="../Pear-Admin-Layui/component/layui/layui.js"></script>
<script src="../Pear-Admin-Layui/component/pear/pear.js"></script>
<!-- 框 架 初 始 化 -->
<script>
    layui.use(['admin', 'jquery', "convert"], function () {
        var admin = layui.admin,
            $ = layui.jquery,
            convert = layui.convert;

        // var image = new Image();
        // image.src = "../Pear-Admin-Layui/admin/images/avatar.jpg";
        // image.onload = function () {
        //     $(".layui-nav-img").attr("src", convert.imageToBase64(image));
        // }

        // 重新设置配置文件读取路径，默认为同级目录下的 pear.config.json
        admin.setConfigPath("../Pear-Admin-Layui/config/pear.config.yml");
        // Admin 框架初始化
        admin.render();

        // 显示名字和头像
        $.ajax({
            url: '/user/name',
            type: 'get',
            dataType: 'json',
            success: function (res) {
                if (res.code == 0) {
                    $("#username").html(res.data.userName);
                    $('.layui-nav-img').attr("src", "../Pear-Admin-Layui/readme/aodi.jpg");
                }
            }
        })


        // 退出登录
        $("#logout").on('click', function () {
            $.ajax({
                url: '/user/logout',
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    layer.msg(res.msg, {
                        offset: '15px'
                        , skin: 'demo-class'
                        , icon: 1
                        , time: 500
                    }, function () {
                        // 后台主页
                        location.href = '/login';
                    });
                }
            })

        })

    })
</script>
</body>
</html>
